// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1

Rectangle {
    width: 480
    height: 480
    focus: true
    color: "#111111"

    property real start_opacity: 0.0

    property int msg_number: 0

    signal finish


    function start(){
        msg_number = 0;
        _timer.start();
    }

    Timer{
        id: _timer
        interval: 500
        repeat: true
        onTriggered: {
            switch(msg_number){
            case 0:
                _msgAnim1.start();
                msg_number++;
                break;
            case 1:
                _msgAnim2.start();
                msg_number++;
                break;
            case 2:
                _msgAnim3.start();
                msg_number++;
                break;
            case 3:
                _msgAnim4.start();
                msg_number++;
                break;
            case 4:
                _msgAnim5.start();
                msg_number++;
                break;
            case 5:
                _msgAnim6.start();
                msg_number++;
                break;
            case 6:
                _msgAnim8.start();
                break;
            case 7:
                _msgAnim7.start();
                break;
            case 8:
                _timer.stop();
                finish();
                break;
            case 9:
                break;
            case 10:
                break;
            case 11:
                break;
            default:
                break;
            }
            msg_number = msg_number;    //switchのバグ対策
        }
    }

    function pressed(key){
        switch(key){
        case Qt.Key_Enter:
        case Qt.Key_Return:
        case Qt.Key_Space:
            if(msg_number > 0){
                _timer.stop();
                finish();
            }
            break;
        default:
            break;
        }
//        console.debug("key");
    }
    function released(key){

    }

    Keys.onPressed: {
        pressed(event.key);
    }

    Text{
        anchors.right: parent.right
        anchors.bottom: parent.bottom
        color: "#555555"
        text: "skip(press enter) >>"
        MouseArea{
            anchors.fill: parent
            onClicked: {
                _timer.stop();
                finish();
            }
        }
    }

    Image{
        id: _msg1
        x: 29
        y: 60
        opacity: start_opacity
        source: "./images/prologue_msg_1.png"
        PrologueMsgAnim{
            id: _msgAnim1
            target: _msg1
        }
    }

    Image{
        id: _msg2
        x: 48
        y: 407
        opacity: start_opacity
        source: "./images/prologue_msg_2.png"
        PrologueMsgAnim{
            id: _msgAnim2
            target: _msg2
        }
    }
    Image{
        id: _msg3
        x: 144
        y: 349
        opacity: start_opacity
        source: "./images/prologue_msg_3.png"
        PrologueMsgAnim{
            id: _msgAnim3
            target: _msg3
        }
    }
    Image{
        id: _msg4
        x: 31
        y: 167
        opacity: start_opacity
        source: "./images/prologue_msg_4.png"
        PrologueMsgAnim{
            id: _msgAnim4
            target: _msg4
        }
    }
    Image{
        id: _msg5
        x: 13
        y: 292
        opacity: start_opacity
        source: "./images/prologue_msg_5.png"
        PrologueMsgAnim{
            id: _msgAnim5
            target: _msg5
        }
    }
    Image{
        id: _msg6
        x: 124
        y: 109
        opacity: start_opacity
        source: "./images/prologue_msg_6.png"
        PrologueMsgAnim{
            id: _msgAnim6
            target: _msg6
        }
    }
    Image{
        id: _msg7
        x: 136
        y: 231
        opacity: start_opacity
        source: "./images/prologue_msg_7.png"
        PrologueMsgAnim{
            id: _msgAnim7
            target: _msg7
            onFinish: {
                msg_number++;
            }
        }
    }

    Image{
        id: _msg8
        x: 13
        y: 344
        opacity: start_opacity
        source: "./images/prologue_msg_8.png"
        PrologueMsgAnim{
            id: _msgAnim8
            target: _msg8
            onFinish: {
                msg_number++;
            }
        }
    }
}
